
<script src=" http://code.jquery.com/ui/1.9.2/jquery-ui.js" ></script>

<script language="javascript">

$(document).ready(function() {

var form = $("#customForm");
var username = $("#gebruikersnaam");
var firstname = $("#voornaam");
var lastname = $("#achternaam");
var email = $("#email");
var pass1 = $("#wachtwoord");
var pass2 = $("#cwachtwoord");

var usernameinfo = $("#infoGebruikersnaam");
var firstnameinfo = $("#infoVoornaam");
var lastnameinfo = $("#infoAchternaam");
var emailinfo = $("#infoEmail");
var pass1Info = $("#infoWachtwoord");
var pass2Info = $("#infoCwachtwoord");

// valideer username


function validateName(){
	//if it's NOT valid
	if(usernname.val().length < 5){
		username.addClass("error");
		usernameInfo.text("Uw username moet minimaal 5 tekens bevatten");
		usernameInfo.addClass("error");
		return false;
	}

	else{
		username.removeClass("error");
		usernameInfo.text("Vul hier uw gebruiksernaam in");
		usernameInfo.removeClass("error");
		return true;
	}
}


//validate wachtwoorden

function validatePass1(){
	var a = $("#wachtwoord");
	var b = $("#cwachtwoord");

	//it's NOT valid
	if(pass1.val().length <5){
		pass1.addClass("error");
		pass1Info.text("Ey! Remember: At least 5 characters: letters, numbers and '_'");
		pass1Info.addClass("error");
		return false;
	}
	//it's valid
	else{			
		pass1.removeClass("error");
		pass1Info.text("At least 5 characters: letters, numbers and '_'");
		pass1Info.removeClass("error");
		validatePass2();
		return true;
	}


}

function validatePass2(){

	var a = $("#password1");
	var b = $("#password2");
	//are NOT valid
	if( pass1.val() != pass2.val() ){
		pass2.addClass("error");
		pass2Info.text("Passwords doesn't match!");
		pass2Info.addClass("error");
		return false;
	}
	//are valid
	else{
		pass2.removeClass("error");
		pass2Info.text("Confirm password");
		pass2Info.removeClass("error");
		return true;
	}
}

})


